#pragma once

#include <linux/kconfig.h>
#include <linux/spinlock.h>
#include <linux/thread_info.h>

#include <linux/sched/sched_types.h>
#include <linux/sched/wake_q.h>

struct sched_class;
struct nsproxy;

struct task_struct
{
    struct thread_info thread_info;

    const struct sched_class *sched_class;
    void *stack;
    struct sched_entity se;
    struct sched_rt_entity rt;
    struct sched_dl_entity dl;
    /* Protection of the PI data structures: */
    raw_spinlock_t pi_lock;
    struct wake_q_node wake_q;
    struct nsproxy *nsproxy;

    unsigned int __state;
    unsigned int saved_state;
    unsigned int flags;
    int on_rq;
    int on_cpu;
    int nr_cpus_allowed;
    short prio;
    short normal_prio;
    short policy;
    unsigned char kthread:1;
    unsigned char idle;
    char name[16];

#ifdef CONFIG_SMP
    unsigned int recent_used_cpu;
    int cpu;
#endif

    /* PI waiters blocked on a rt_mutex held by this task: */
    struct rb_root_cached pi_waiters;
    /* Updated under owner's pi_lock and rq lock */
    struct task_struct *pi_top_task;
    /* Deadlock detection and priority inheritance handling: */
    struct rt_mutex_waiter *pi_blocked_on;

    void *filedesc;

    /* PF_KTHREAD | PF_IO_WORKER */
    void *worker_private;
};
